<?php
use yii\helpers\Html;
use yii\helpers\Url;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use frontend\assets\AppAsset;
use yii\widgets\ActiveForm;
use frontend\models\register\RegisterForm;
use frontend\models\login\LoginForm;
use common\widgets\Alert;
use backend\models\system\SysConfig;

//微博I第三方登录
use vendor\weibo\SaeTOAuthV2;
define( "WB_AKEY" , '3754678628' );
define( "WB_SKEY" , 'bf45920410c548a6ad12009940922e95' );
define( "WB_CALLBACK_URL" , 'http://www.bwphp.com/callback.php' );
session_start();
$o = new SaeTOAuthV2( WB_AKEY , WB_SKEY );
$code_url = $o->getAuthorizeURL( WB_CALLBACK_URL );


$register = new RegisterForm();
$login = new LoginForm();
/* @var $this \yii\web\View */
/* @var $content string */




AppAsset::register($this);
?>

<?php $this->beginPage() ?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<!-- <link rel="stylesheet" type="text/css" href="/assets/style/style.css"> -->
	<?= Html::jsFile('/assets/1902591f/jquery.js')?>
	<link rel="stylesheet" type="text/css" href="/assets/css/public.css"/>
	<link rel="stylesheet" type="text/css" href="/assets/style/form.css">
	<link rel="stylesheet" type="text/css" href="/assets/css/gerenzhognxin1.css"/>
<link rel="stylesheet" type="text/css" href="/assets/css/public1.css"/>
	<title><?= Html::encode($this->title) ?></title>
</head>
<body>
<!-- <div id="box">
	<div class="head">
		<ul>
			<li><a href="<?php echo Yii::$app->request->hostInfo;?>">首页</a></li>
			<li><a href="<?php echo Yii::$app->urlManager->createUrl('course/index')?>">课程</a></li>
			<li><a href="#">下载</a></li>
			<li><a href="#">有问必答</a></li>
			<li><a href="#">师资力量</a></li>
			<li><a href="<?php echo Yii::$app->urlManager->createUrl('operate/index')?>">行业咨询</a></li>
		</ul>
		<form action="#" method="post">
			<input  type="text" class="txt" placeholder="输入内容"/><input type="button" value="搜索"  class="btn1"/>	
		<?= Html::Button('登录', ['class' => 'btn1','id'=>'login']) ?>
		<?= Html::Button('注册', ['class' => 'btn2','id'=>'register']) ?>
		</form>
		
	</div> -->
	<!--这是导航-->
	<div class="nav_outer">
		<div class="nav">
			<input type="text" class="kuang132" />
			<ul>
				<li><a href="<?php echo Yii::$app->request->hostInfo;?>">首页</a></li>
				<?php
					$model = new SysConfig();
					$model->config_type = '4';
					$data = $model->getValueByType();
					foreach($data as $k=>$v){
						$res = unserialize($v['config_value']);
						if($res['nav_status'] == '1'){
							$arr[] = $res;
						}
					}
					foreach($arr as $k=>$v){
						echo "<li><a href=".Yii::$app->urlManager->createUrl($v['nav_url']).">".$v['nav_name']."</a></li>";
				} ?>
			</ul>
				<input type="text" value="输入内容" class="kuang221" />
				<input type="image" src="/assets/image/zaixian_06.gif" class="sou" />
				<?php
					$session = Yii::$app->session;
					$session->open();

					$cookies = Yii::$app->request->cookies;
			
					if(!empty($cookies->getValue('user_id'))){
						$session->set('user_id',$cookies->getValue('user_id'));
						$session->set('user_thumb',$cookies->getValue('user_thumb'));
						$session->set('user_num',$cookies->getValue('user_num'));
						$session->set('user_emid',$cookies->getValue('user_emid'));
					}
					if($session->get('user_id')){
				?>
				<input type="image" src="/assets/images/aa_11.gif" class="tu2"/>
				<input type="image" src="/assets/images/aa_08.gif" class="tu3"/>
				<input type="image" src="/assets/images/aa_14.gif" class="tu4"/>
				<input type="image" src="/assets/images/aa_05.gif" class="tu5"/>
				<div class="box" style="height:341px">
					<div class="minibox"> 
					  <a href="#"><img src="images/sajia_03.gif"/></a>
					  <div class="miniyou">
						  <h4><a href="#">呆萌的洒家</a></h4>
							<p><a href="#">金币：<span>0</span></a></p>
					  </div>
				  </div>
					<ul>
						<li class="bg1"><a href="<?= Url::to(['center/index'])?>">个人中心</a></li>
						<li class="bg2"><a href="#">添加好友</a></li>
						<li class="bg3"><a href="#">在线充值</a></li>
						<li class="bg4"><a href="#">已购买课程</a></li>
						<li class="bg5"><a href="#">历史浏览</a></li><input type="image" src="/assets/images/sajia_27.gif" id='loginout'/>
					</ul>
				</div>
				<?php }else{?>
				<input type="button" value="登录" id='login' class="btn1" />
				<input type="button" value="注册" id='register' class="btn2"/>
				<?php }?>
		</div>
	</div>
<?php $this->beginBody() ?>

<div class="wrap">
    <!-- <?php
    NavBar::begin([
        'brandLabel' => 'My Company',
        'brandUrl' => Yii::$app->homeUrl,
        'options' => [
            'class' => 'navbar-inverse navbar-fixed-top',
        ],
    ]);
    $menuItems = [
        ['label' => 'Home', 'url' => ['/site/index']],
    ];
    if (Yii::$app->user->isGuest) {
        $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
    } else {
        $menuItems[] = [
            'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
            'url' => ['/site/logout'],
            'linkOptions' => ['data-method' => 'post']
        ];
    }
    echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-right'],
        'items' => $menuItems,
    ]);
    NavBar::end();
    ?> -->

    <div class="container">
        <!-- <?= Breadcrumbs::widget([
            'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
        ]) ?>
        <?= Alert::widget() ?>-->
        		
        <?= $content ?> 
		<!--弹框-->
		<div class="greybg"></div>
		<!--注册-->
		<div class="popup registerpop" style="height: 500px;">
        <h2 class="popuptit"><span class="close"></span>用户注册</h2>
		<div class="logindiv">
			<?php $form = ActiveForm::begin(['action' =>Url::to(['index/register']),'method'=>'post','id' => 'register-form']); ?>
			<div class="loginli"><?= $form->field($register, 'user_name')->textInput(['class'=>'alltext logintext','placeholder'=>'昵称为2-18位,中英文、数字、下划线']) ?><font color='red'><span id="uname"></span></font></div>
			<div class="loginli"><?= $form->field($register, 'user_pwd')->textInput(['class'=>'alltext passtext','placeholder'=>'请输入密码']) ?></div>
			<div class="loginli"><?= $form->field($register, 'user_qrpwd')->textInput(['class'=>'alltext passtext','placeholder'=>'请再次输入密码']) ?></div>
			<div class="loginli"><?= $form->field($register, 'user_email_phone')->textInput(['class'=>'alltext logintext phoneico','placeholder'=>'请输入手机号或邮箱']) ?></div>
			<div class="loginli"><?= $form->field($register, 'user_code')->textInput(['class'=>'alltext yzmtext','placeholder'=>'请输入验证码']) ?><input id="zphone" class='code' type="button" value=" 获取手机验证码 "></div>
			<div class="loginli"><input type="checkbox" name="service_content" checked disabled>&nbsp;&nbsp;&nbsp;&nbsp;<a href="index.php<?= Url::to(['index/service_content'])?>" target="_blank">用户注册条款点击查看详情</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color='red'>(*)必须被选中</font></div>
			<div class="form-group">
				<?= Html::submitButton('立即注册', ['class' => 'loginbtn','id'=>'regloginbtn']) ?>
			</div>
			<?php ActiveForm::end(); ?>
			<div class="ihaveaccountnum">已有账号，<a href="javascript:void(0)" id="Login">请登录</a></div>
		</div>
		
	</div>
		<!--登陆弹窗开启-->
		<div class="popup loginpop" style="height: 500px;" id="loginpop">
			<h2 class="popuptit"><span class="close"></span>登录</h2>
			<div class="logindiv">
			<?php $form = ActiveForm::begin(['action' =>\Yii::$app->urlManager->createUrl('index/login'),'method'=>'post','id' => 'login-form']); ?>
				<div class="loginli"><?= $form->field($login, 'user_name')->textInput(['class'=>'alltext logintext','placeholder'=>'请输入昵称,手机号或电子邮箱']) ?></div>
				<div class="loginli"><?= $form->field($login, 'user_pwd')->textInput(['class'=>'alltext passtext','placeholder'=>'请输入密码']) ?></div>
				<div class="lrremeberdiv"><?= $form->field($login, 'rememberMe')->checkbox() ?><a href="javascript:void(0)"  class="forgeta" id="forget">忘记密码？</a></div>
				<?= Html::submitButton('登录', ['class' => 'loginbtn','id'=>'loginbtn']) ?>
				<a href="javascript:void(0)" class="regaa">立即注册</a>
				<?php ActiveForm::end(); ?>
				<p class="loginp1">其它账号登录</p>
				<p class="loginp2">
					<a href="index.php/site/auth?authclient=qq" title="QQ登录"><img src="/assets/img/qq.jpg" width="25" height="25"/></a>
					<a href="#" title="微信登录"><img src="/assets/img/weixin.jpg" width="25" height="25"/></a>
					<a href="<?=$code_url?>" title="新浪微博登录"><img src="/assets/img/weibo.png" width="25" height="25"/></a>
				</p>
			</div>
			
		</div>
		<!--登陆弹窗结束-->
		<!--忘记密码-->
		<div class="popup forget" style="height: 500px;">
			<h2 class="popuptit"><span class="close"></span>忘记密码</h2>
			<div class="headscimg">
				<input type="text" id='forgetpwd' placeholder='请输入手机或邮箱'>
			</div>
			<div class="headscimg">
				验证码：<input type="text" class='phone_code' id='phone' placeholder='请输入验证码' ><input id="fphone" class='fcode' type="button" value=" 获取验证码 "><span id='pcode'></span>
			</div>
			<div class="headscimg">
				<?= Html::Button('下一步',['disabled'=>true,'id'=>'next']) ?>
			</div>
			
		</div>
		<!--忘记密码结束-->
		<!-- 新密码 -->
		<div class="popup newpwd">
			<div class="headscimg">
				新密码：<input type="password" id='newpwd'><span id='usernewpwd'></span>
			</div>
			<div class="headscimg">
				确认密码：<input type="password" id='rightnewpwd'><span id='qnewpwd'></span>
			</div>
			<div class="headscimg">
				<?= Html::Button('修改',['disabled'=>true,'id'=>'save_pwd']) ?>
			</div>
		</div>
		<!-- 新密码结束 -->
		<!-- 修改成功 -->
		<div class="popup success">
			<div class="headscimg">
				<h1><font color='red'>恭喜您操作成功</font></h1>
			</div>
			<div class="headscimg">
				<?= Html::Button('确定',['id'=>'success']) ?>
			</div>
		</div>
<!-- <footer class="footer"> -->
    <div class="container">
        <!-- <p class="pull-left">&copy; My Company <?= date('Y') ?></p>
            
        <p class="pull-right"><?= Yii::powered() ?></p> -->
<div class="footer_outer">
  <div class="footer">
  	<div class="footer1">
    	<p>
        	<a href="#">关于我们</a><span>|</span>
            <a href="#">意见反馈</a><span>|</span>
            <a href="#">功能与帮助</a><span>|</span>
            <a href="#">在线客服</a><span>|</span>
            <a href="#">管理登录</a>
        </p>
        <p>
        	Copyright &copy; 2014 超星集团旗下网站-尔雅学习中心 京ICP:13010077 网络视听许可证:01104338号
        </p>
    </div>
    <div class="footer2">
    	<p>客服电话：400-6606-211</p>
        <p>客服邮箱：mc@erya100.com</p>
    </div>
  </div>
</div> 
           
    </div>
	<!--底部-->
 
<!-- </footer> -->

 <?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
<script>
//弹窗    
function popup(){
	$("body").css({height:"100%"});
	$(".greybg").fadeIn(100);
};

function closepop(){
	window.goUrl = '';
	$("body").removeAttr("style");
	$(".greybg").fadeOut(100);
};
	$(function(){
			$(".btn2").click(function(){
				popup();
				$(".registerpop").fadeIn(100);
			})
			$(".btn1").click(function(){
				popup();
				$(".loginpop").fadeIn(100);
			})
			$(".guanbidiv").click(function(){
				closepop();
				$(this).parents(".popup").fadeOut(100);
			});
			$(".popuptit .close").click(function(){
				closepop();
				$(this).parents(".popup").fadeOut(100);
			});
		}
	)
	$('#registerform-user_name').blur(function(){
			var user_name = $(this).val();
			$.ajax({
			   //type: "GET",
			   //url: "index.php<?= Url::to(['index/codes'])?>?email_phone="+email_phone,
			   type: "POST",
			   url: "<?= Url::to(['index/unique'])?>",
			   data: "user_name="+user_name,
			   success: function(msg){
					if(msg == 1){
						$('#uname').html('当前昵称已被使用');
					}else{
						$('#uname').html('');
					}
			   }
		});
		}
	)
	$("#Login").click(function(){
		$(".registerpop").css('display','none');
		$("#loginpop").css('display','block');
	});
	$("#forget").click(function(){
		$("#loginpop").css('display','none');
		$(".forget").css('display','block');
	})
	$(".regaa").click(function(){
		$(".registerpop").css('display','block');
		$("#loginpop").css('display','none');
	});
	$(".code").click(function(){
		//var csrfToken = $('meta[name="csrf-token"]').attr("content");
		//alert(csrfToken);die;
		var email_phone = $("#registerform-user_email_phone").val();
		if(email_phone == ""){
			alert('请输入邮箱或者手机');die;
		}
		$.ajax({
		   //type: "GET",
		   //url: "index.php<?= Url::to(['index/codes'])?>?email_phone="+email_phone,
		   type: "POST",
		   url: "<?= Url::to(['index/codes'])?>",
		   data: "email_phone="+email_phone,
		   success: function(msg){
			 if(msg == 1){
				RemainTime();
				alert('验证码已发送成功,请注意查收')		
			 }else if(msg == 2){
				alert('发送邮件失败,请重新获取验证码')		
			 }else if(msg == 3){
				alert('请输入正确的邮箱或手机号')		
			 }
		   }
		});
	})
	//修改密码获取验证码
	$(".fcode").click(function(){
		var email_phone = $("#forgetpwd").val();
		if(email_phone == ""){
			alert('请输入邮箱或者手机');die;
		}
		$.ajax({
		   //type: "GET",
		   //url: "index.php<?= Url::to(['index/codes'])?>?email_phone="+email_phone,
		   type: "POST",
		   url: "<?= Url::to(['index/codes'])?>",
		   data: "email_phone="+email_phone,
		   success: function(msg){
			 if(msg == 1){
				RemainTimes();
				alert('验证码已发送成功,请注意查收')		
			 }else if(msg == 2){
				alert('发送邮件失败,请重新获取验证码')		
			 }else if(msg == 3){
				alert('请输入正确的邮箱或手机号')		
			 }
		   }
		});
	})

	var iTime = 59;
	var Account;
	function RemainTime(){
		document.getElementById('zphone').disabled = true;
		var iSecond,sSecond="",sTime="";
		if (iTime >= 0){
			iSecond = parseInt(iTime%60);
			iMinute = parseInt(iTime/60)
			if (iSecond >= 0){
				if(iMinute>0){
					sSecond = iMinute + "分" + iSecond + "秒";
				}else{
					sSecond = iSecond + "秒后再次获取";
				}
			}
			sTime=sSecond;
			if(iTime==0){
				clearTimeout(Account);
				sTime='获取验证码';
				iTime = 59;
				document.getElementById('zphone').disabled = false;
			}else{
				Account = setTimeout("RemainTime()",1000);
				iTime=iTime-1;
			}
		}else{
			sTime='没有倒计时';
		}
		document.getElementById('zphone').value = sTime;
	}
	function RemainTimes(){
		document.getElementById('fphone').disabled = true;
		var iSecond,sSecond="",sTime="";
		if (iTime >= 0){
			iSecond = parseInt(iTime%60);
			iMinute = parseInt(iTime/60)
			if (iSecond >= 0){
				if(iMinute>0){
					sSecond = iMinute + "分" + iSecond + "秒";
				}else{
					sSecond = iSecond + "秒后再次获取";
				}
			}
			sTime=sSecond;
			if(iTime==0){
				clearTimeout(Account);
				sTime='获取验证码';
				iTime = 59;
				document.getElementById('fphone').disabled = false;
			}else{
				Account = setTimeout("RemainTimes()",1000);
				iTime=iTime-1;
			}
		}else{
			sTime='没有倒计时';
		}
		document.getElementById('fphone').value = sTime;
	}
	//检验密码
	$("#phone").blur(function(){
	var phone = $("#forgetpwd").val();
	var code = $(this).val()
	$.ajax({
		   type: "POST",
		   url: "<?= Url::to(['center/validationcodes'])?>",
		   data: "phone="+phone+"&code="+code,
		   success: function(msg){
			 if(msg==1){
				document.getElementById('next').disabled = true;
				$('#pcode').html('验证码不能为空');
			 }else if(msg==2){
				 document.getElementById('next').disabled = false;
				 $('#pcode').html('');
			 }else{
				document.getElementById('next').disabled = true;
				$('#pcode').html('验证码错误');
			 }
		   }
		});
	})
	$("#next").click(function(){
		$(".forget").css('display','none');
		$(".newpwd").css('display','block');
	})
	//修改新密码
	$("#newpwd").blur(function(){
		var newpwd = $(this).val();
		if(newpwd==""){
			$("#usernewpwd").html('请输入密码');
		}else if(newpwd.length<6 || newpwd.length>18){
			$("#usernewpwd").html('请输入6-18位密码');
		}else{
			$("#usernewpwd").html('');
		}
	})
	$("#rightnewpwd").blur(function(){
		var rightnewpwd = $(this).val();
		var newpwd = $("#newpwd").val();
		if(rightnewpwd==""){
			$("#qnewpwd").html('请输入确认密码');
		}else if(rightnewpwd!=newpwd){
			$("#qnewpwd").html('确认密码与密码不匹配');
		}else{
			$("#qnewpwd").html('');
			document.getElementById('save_pwd').disabled = false;
		}
		
	})
	$("#save_pwd").click(function(){
		var email_phone = $("#forgetpwd").val()
		var user_pwd = $("#rightnewpwd").val();
		$.ajax({
		   type: "POST",
		   url: "<?= Url::to(['center/savepwd'])?>",
		   data: "email_phone="+email_phone+"&user_pwd="+user_pwd,
		   success: function(msg){
			 if(msg == 1){
				$(".newpwd").css('display','none');
				$(".success").css('display','block');
			 }
		   }
		});
	})
	//成功后跳转
	$("#success").click(function(){
	location.href="<?= Url::to(['site/index'])?>";
	})
	$(".tu5").click(function(){
		location.href="<?= Url::to(['center/index'])?>";
	});
	$("#loginout").click(function(){
		if(confirm('确定退出吗?')){
			location.href="<?= Url::to(['index/loginout'])?>";
		}else{
			return false;
		}
	})
</script>